Skip to main content

1.4. Processing request examples

Briefly the stages of processing the request examples:​

  1. Encoding and Signature Generation:
    • The message container is JSON.
    • The JSON string is Base64 encoded.
    • The signature is generated as a lowercase hex SHA1 hash (base64 encoded) from the concatenation of the data and merchantID parameters.
    • Before being sent, equal signs in request parameters are escaped with urlencode.
  2. Transport Protocols:
    • When connected via LAN or Serial device port, the API implements interoperability.
    • When connected via LAN:
      • HTTP protocol is used as a transport.
      • Default port is 8008.
      • Requests are sent using the POST method.
    • When communicating via Serial port:
      • Transport packet format: (STX)data(CRC 32)(ETX).
      • STX is 0x02, ETX is 0x03.
      • CRC32 is calculated from the packet data.
      • Characters with the code 0x03 are replaced by 0x20.
  3. Request Parameters:
    • The request has two parameters: data (the message) and sign (the signature).
    • When interacting through the Serial port, the command parameter is added, containing the request endpoint.

Merchant ID example:

9662a13f5b4f46dbb1751bbbf86ed402

Request Data example:

{
"docNumber": "123",
"employeeName": "Ivanov",
"amount": 15000,
"currency": "AZN",
"items": [
{
"itemId": "1111",
"itemName": "Water",
"itemQRCode": "",
"itemQty": 2000,
"itemAmount": 15000,
"discount": 0,
"itemTaxes": [
{
"taxName": "VAT",
"taxPrc": 1800
}
]
}
],
"payments": {
"cashAmount": 15000,
"cashlessAmount": 0,
"otherAmount": 0
}
}

Data Parameter example:

eyJkb2NOdW1iZXIiOiAgIjEyMyIsImVtcGxveWVlTmFtZSI6ICLQmNCy0LDQvdC+0LIiLCJhbW91bnQiOiAgMTUwMDAsImN1cnJlbmN5IjogIkFaTiIsCiAiaXRlbXMiOiBbeyJpdGVtSWQiOiAiMTExMSIsICJpdGVtTmFtZSI6ICLQodC10LzQtdGH0LrQuCIsICJpdGVtUVJDb2RlIjogIiIsICJpdGVtUXR5IjogMjAwMCwKICJpdGVtQW1vdW50IjogMTUwMDAsImRpc2NvdW50IjogMCwiaXRlbVRheGVzIjogW3sidGF4TmFtZSI6ICLQndCU0KEiLCJ0YXhQcmMiOiAxODAwfV19XSwKICJwYXltZW50cyIgOiB7ImNhc2hBbW91bnQiOiAxNTAwMCwiY2FzaGxlc3NBbW91bnQiOiAwLCJvdGhlckFtb3VudCI6IDB9fQ%3D%3D

SHA1 example:

fce95529d72466191683e02b17a8b1204c165a49

Sign Parameter example:

ZmNlOTU1MjlkNzI0NjYxOTE2ODNlMDJiMTdhOGIxMjA0YzE2NWE0OQ%3D%3D

Request body example:

data=eyJkb2NOdW1iZXIiOiAgIjEyMyIsImVtcGxveWVlTmFtZSI6ICLQmNCy0LDQvdC+0LIiLCJhbW91bnQiOiAgMTUwMDAsImN1cnJlbmN5IjogIkFaTiIsCiAiaXRlbXMiOiBbeyJpdGVtSWQiOiAiMTExMSIsICJpdGVtTmFtZSI6ICLQodC10LzQtdGH0LrQuCIsICJpdGVtUVJDb2RlIjogIiIsICJpdGVtUXR5IjogMjAwMCwKICJpdGVtQW1vdW50IjogMTUwMDAsImRpc2NvdW50IjogMCwiaXRlbVRheGVzIjogW3sidGF4TmFtZSI6ICLQndCU0KEiLCJ0YXhQcmMiOiAxODAwfV19XSwKICJwYXltZW50cyIgOiB7ImNhc2hBbW91bnQiOiAxNTAwMCwiY2FzaGxlc3NBbW91bnQiOiAwLCJvdGhlckFtb3VudCI6IDB9fQ%3D%3D&sign=ZmNlOTU1MjlkNzI0NjYxOTE2ODNlMDJiMTdhOGIxMjA0YzE2NWE0OQ%3D%3D

Pre-request script example:

r = pm.request.body.raw
merchant_id = '14debbce5c0a44718e86371d55b45ffd'

r=Buffer.from(r).toString('base64')
hash = CryptoJS.SHA1(r+merchant_id).toString();
sign = Buffer.from(hash).toString('base64')

body= 'data='+r.replaceAll('=','%3D')+'&sign='+sign.replaceAll('=','%3D')
console.log(r,hash,sign,body)

pm.request.body.raw= body

JSON Postman Collection download link:

Fiscal.postman_collection.json